'use strict';

const Controller = require('./base');

class ActController extends Controller {

  // 界面列表
  async list() {
    const ctx = this.ctx;
    ctx.set('Content-Type', 'application/json');
    const list = await ctx.service.vote.list(ctx.query);
    this.success(list);
  }


  // 删除界面
  async clear() {
    const ctx = this.ctx;
    ctx.set('Content-Type', 'application/json');
    // const created = await ctx.service.vote.del(id);
    this.success({
      msg: "删除成功"
    })
  }

  // 投票
  async vote() {
    const ctx = this.ctx;
    const post = ctx.request.body;
    if (post.uid == undefined || post.aid == undefined) {
      this.ctx.throw(500, '参数错误');
      return;
    }
    ctx.set('Content-Type', 'application/json');
    const created = await ctx.service.act.vote(post);
    this.success({
      msg: "投票成功"
    })
  }

}

module.exports = ActController;
